package de.beuth.hochschule.ats.util;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

import android.R;

public class LanguageMap extends LinkedHashMap<String, String> {

	private static final long serialVersionUID = 1L;

	private static LanguageMap instance = null;
	
	public static LanguageMap getInstance() {
		if (instance == null) {
			instance = new LanguageMap();
		}
		return instance;
	}
	
	public LanguageMap() {
		TreeMap<String, String> availableLanguages = new TreeMap<String, String>();
//		TreeMap<String, String> otherLanguages = new TreeMap<String, String>();
		for (Locale l: Locale.getAvailableLocales()) {
			availableLanguages.put(l.getDisplayLanguage(), l.getISO3Language());
		}
//		Locale l;
//		for (String s: Locale.getISOLanguages()) {
//			l = new Locale(s);
//			otherLanguages.put(l.getDisplayLanguage(), l.getISO3Language());
//		}
		for (Map.Entry<String, String> entry: availableLanguages.entrySet()) {
			put(entry.getKey(), entry.getValue());
		}
//		for (Map.Entry<String, String> entry: otherLanguages.entrySet()) {
//			put(entry.getKey(), entry.getValue());
//		}
	}
	
	public ArrayList<String> getDisplayLanguages() {
		return new ArrayList<String>(this.keySet());
	}
	
	public ArrayList<String> getIso3Languages() {
		return new ArrayList<String>(this.values());
	}
	
}
